home *** CD-ROM | disk | FTP | other *** search
- /*
- * illustrates the use of extended tty charatersitics
- *
- * If _ABI_SOURCE is defined, use the ``termios'' structure and
- * provided routines instead of the ``ltchars'' struct
- */
- #ifdef _ABI_SOURCE
- #define SVR4
- #endif
-
- #include <stdio.h>
- #include <sys/types.h>
- #ifdef SVR4
- #include <sys/termios.h>
- #else
- #include <sys/ioctl.h>
- #endif
-
- #ifdef SVR4
- struct termios old_tty, new_tty;
- #else
- #ifdef TIOCSLTC
- struct ltchars old_chars, new_chars;
- #endif
- #endif
-
- main ()
- {
- #ifdef SVR4
- /*
- * save off ltchars settings,
- * and change some - SVR4 flavor
- */
- tcgetattr (fileno (stdin), &old_tty);
- new_tty = old_tty;
- if (old_tty.c_cc[VLNEXT] == CTRL('v'))
- new_tty.c_cc[VLNEXT] = -1;
- if (old_tty.c_cc[VRPRNT] == CTRL('r'))
- new_tty.c_cc[VRPRNT] = -1;
- tcsetattr (fileno (stdin), TCSAFLUSH, &new_tty);
- #else /* !SVR4 */
- #ifdef TIOCSLTC
- /*
- * save off ltchars settings,
- * and change some
- */
- (void)ioctl(fileno(stdin), TIOCGLTC, (char *)&old_chars);
- new_chars = old_chars;
- if (old_chars.t_lnextc == ctl('v'))
- new_chars.t_lnextc = -1;
- if (old_chars.t_rprntc == ctl('r'))
- new_chars.t_rprntc = -1;
- (void)ioctl(fileno(stdin), TIOCSLTC, (char *)&new_chars);
- #endif
- #endif
- }
-
- /*
- * on program exit, restore old ltchars settings
- */
- void
- on_quit()
- {
- #ifdef SVR4
- tcsetattr (fileno (stdin), TCSAFLUSH, &old_tty);
- #else /* !SVR4 */
- #ifdef TIOCSLTC
- (void)ioctl(fileno(stdin), TIOCSLTC, (char *)&old_chars);
- #endif
- #endif
- }
-